package at.fhv.androideightpuzzle.network.message;

import org.json.simple.JSONObject;

public class PuzzleSolvedMessage implements IMessage{
	
	public static final int TYPE=3;
	
	private String m_playerName;
	private long m_seconds;
	
	public PuzzleSolvedMessage(String playerName,long seconds){
		m_playerName=playerName;
		m_seconds=seconds;
	}
	
	@SuppressWarnings("unchecked")
	public String getJson() {
		JSONObject jsonObj=new JSONObject();
		
		jsonObj.put("type",PuzzleSolvedMessage.TYPE);
		
		JSONObject payload=new JSONObject();
		
		payload.put("playername",m_playerName);
		payload.put("time",m_seconds);
		
		jsonObj.put("payload",payload);
		
		return jsonObj.toJSONString();
	}
	
	public String getPlayerName(){
		return m_playerName;
	}
	
	public long getSeconds(){
		return m_seconds;
	}
}
